package com.geek.bams.vo;

import com.geek.bams.service.Bank;

import java.util.Objects;

/*
 *@author wangpeng
 *2025/10/21 18:39
 *@description TODO
 */

/**
 * RankVO辅助类，可以在有需要展示personID、name、total时使用，
 * 这些需要展示的数据，可能需要计算，只要展示就需要计算，则多次计算
 * 那这里就直接创建RankVO辅助类，之后只需要把RankVO传递给Swing界面即可
 */
public class RankVO implements Comparable<RankVO>{
    //身份证号
    private String personID;
    //姓名
    private String name;
    //总资产
    private double total;

    public RankVO() {
    }

    public RankVO(String personID, String name, double total) {
        this.personID = personID;
        this.name = name;
        this.total = total;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RankVO rankVO = (RankVO) o;
        return Double.compare(total, rankVO.total) == 0 && Objects.equals(personID, rankVO.personID) && Objects.equals(name, rankVO.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(personID, name, total);
    }
    //RankVO implements Comparable<RankVO>，则需要重写compareTo()方法
    @Override
    public int compareTo(RankVO o) {
        // 按总资产降序排列,当总资产相同时，按身份证号升序排列
        if(this.total == o.total){
            return this.personID.compareTo(o.personID);
        }
        return Double.compare(o.total, this.total);
    }

    /**
     * 获取
     * @return personID
     */
    public String getPersonID() {
        return personID;
    }

    /**
     * 设置
     * @param personID
     */
    public void setPersonID(String personID) {
        this.personID = personID;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return total
     */
    public double getTotal() {
        return total;
    }

    /**
     * 设置
     * @param total
     */
    public void setTotal(double total) {
        this.total = total;
    }

    public String toString() {
        return "RankVO{personID = " + personID + ", name = " + name + ", total = " + total + "}";
    }
}
